import { Injectable } from '@nestjs/common';
import { ConfigService as NestConfigService } from '@nestjs/config';

@Injectable()
export class ConfigService {
  constructor(private configService: NestConfigService) {}

  // 币安配置
  get binanceApiKey(): string {
    return this.configService.get<string>('BINANCE_API_KEY');
  }

  get binanceSecretKey(): string {
    return this.configService.get<string>('BINANCE_SECRET_KEY');
  }

  get binanceDemoTrading(): boolean {
    return this.configService.get<string>('BINANCE_DEMO_TRADING') === 'true';
  }

  // DeepSeek配置
  get deepseekApiKey(): string {
    return this.configService.get<string>('DEEPSEEK_API_KEY');
  }

  get deepseekBaseUrl(): string {
    return this.configService.get<string>('DEEPSEEK_BASE_URL');
  }

  // 交易配置
  get tradingSymbol(): string {
    return this.configService.get<string>('TRADING_SYMBOL', 'BTCUSDT');
  }

  get tradingInterval(): string {
    return this.configService.get<string>('TRADING_INTERVAL', '5m');
  }

  get maxPositionSize(): number {
    return parseFloat(this.configService.get<string>('MAX_POSITION_SIZE', '0.01'));
  }

  get riskPercentage(): number {
    return parseFloat(this.configService.get<string>('RISK_PERCENTAGE', '2'));
  }

  get stopLossPercentage(): number {
    return parseFloat(this.configService.get<string>('STOP_LOSS_PERCENTAGE', '2'));
  }

  get takeProfitPercentage(): number {
    return parseFloat(this.configService.get<string>('TAKE_PROFIT_PERCENTAGE', '4'));
  }

  // 激进交易模式配置
  get aggressiveMode(): boolean {
    return this.configService.get<string>('AGGRESSIVE_MODE', 'false') === 'true';
  }

  get aggressiveConfidenceThreshold(): number {
    return parseFloat(this.configService.get<string>('AGGRESSIVE_CONFIDENCE_THRESHOLD', '30'));
  }

  get aggressiveRiskMultiplier(): number {
    return parseFloat(this.configService.get<string>('AGGRESSIVE_RISK_MULTIPLIER', '1.5'));
  }

  // 系统配置
  get logLevel(): string {
    return this.configService.get<string>('LOG_LEVEL', 'info');
  }

  get analysisInterval(): number {
    return parseInt(this.configService.get<string>('ANALYSIS_INTERVAL', '900000'));
  }

  // 代理配置
  get proxyHost(): string {
    return this.configService.get<string>('PROXY_HOST', '127.0.0.1');
  }

  get proxyPort(): number {
    return parseInt(this.configService.get<string>('PROXY_PORT', '7890'));
  }

  get useProxy(): boolean {
    return this.configService.get<string>('USE_PROXY', 'true') === 'true';
  }
}